package edu.nf.waimai.dao.admin.impl;

import org.nf.db.util.SqlExecutor;
import edu.nf.util.DBUtils;
import edu.nf.waimai.dao.admin.OrderMarkDao;
import org.nf.db.util.result.ColumnHandler;

import java.math.BigDecimal;


/**
 * @Date 2023-09-10
 * @Author qiu
 */
public class OrderMarkDaoImpl implements OrderMarkDao {
    @Override
    public Long queryUserOrderCount() {
        SqlExecutor executor = new SqlExecutor(DBUtils.getConnection());
        String sql = "select count(u_id) from orders where order_status = 6;";
        ColumnHandler<Long> columnHandler = new ColumnHandler(1);
        return executor.executeQuery(sql, columnHandler);
    }

    @Override
    public Long queryShopOrderCount() {
        SqlExecutor sqlExecutor = new SqlExecutor(DBUtils.getConnection());
        String sql = "select count(shop_id) from orders where order_status = 6;";
        ColumnHandler<Long> columnHandler = new ColumnHandler<>(1);
        return sqlExecutor.executeQuery(sql, columnHandler);
    }

    @Override
    public Long queryRiderOrderCount() {
        SqlExecutor sqlExecutor = new SqlExecutor(DBUtils.getConnection());
        String sql = "select count(rider_id) from orders where order_status = 6";
        ColumnHandler<Long> columnHandler = new ColumnHandler<>(1);
        return sqlExecutor.executeQuery(sql, columnHandler);
    }

    @Override
    public BigDecimal queryAllCount() {
        SqlExecutor sqlExecutor = new SqlExecutor(DBUtils.getConnection());
        String sql = "select sum(total_price) from orders where order_status = 6 ";
        ColumnHandler<BigDecimal> columnHandler = new ColumnHandler<>(1);
        return sqlExecutor.executeQuery(sql,columnHandler);
    }
}
